package com.example.win.android_banduyujia.http;

import org.json.JSONObject;

/**
 * Created by Win on 2015/8/24.
 */
public class HttpResult {
    public static final int HTTP_RESULT_CODE_SUCCESS = 0;

    public static final int HTTP_RESULT_CODE_FAILED = 1;
    public static final int HTTP_RESULT_CODE_NET_OFF = 2;
    public static final int HTTP_RESULT_CODE_EXCEPTION = 3;
    public static final int HTTP_RESULT_CODE_IO_EXCEPTION = 4;

    public static final int ACK_SERVER_MAINTENANCE = 10001;
    public static final int ACK_TOO_MANY_REQUEST_AT_MOMENT = 10002;
    public static final int ACK_HTTP_METHOD_NOT_SUPPORT = 10003;
    public static final int ACK_INVALID_PARAMETER = 2000;
    public static final int ACK_SERVER_SIDE_ERROR = 20002;
    public static final int ACK_GAME_NOT_EXIST = 20003;
    public static final int ACK_CATEGORY_NOT_EXIST = 20004;
    public static final int ACK_INVALID_TOKEN = 30001;
    public static final int ACK_TOKEN_OUT_OF_DATE = 30002;

    public static final String ACK_STRING_SERVER_MAINTENANCE = "Server maintenance";
    public static final String ACK_STRING_TOO_MANY_REQUEST_AT_MOMENT = "Too many request at the moment";
    public static final String ACK_STRING_HTTP_METHOD_NOT_SUPPORT = "HTTP method not support";
    public static final String ACK_STRING_INVALID_PARAMETER = "Invalid Parameter";
    public static final String ACK_STRING_SERVER_SIDE_ERROR = "Server side error";
    public static final String ACK_STRING_GAME_NOT_EXIST = "Game does not exist";
    public static final String ACK_STRING_CATEGORY_NOT_EXIST = "Category does not exist";
    public static final String ACK_STRING_INVALID_TOKEN = "Invalid Token";
    public static final String ACK_STRING_TOKEN_OUT_OF_DATE = "Token out of date";

    private int mHttpStatus;
    private int mErrorCode;
    private boolean mIsConnected;
    private String  mErrorMessage;
    private JSONObject mJSON;
    private String mData;

    public HttpResult(){
        mHttpStatus = 0;
        mErrorMessage = " ";
        mErrorCode = HTTP_RESULT_CODE_SUCCESS;
        mIsConnected = false;
        mJSON = null;
        mData = null;
    }

    public int getHttpStatus() {
        return mHttpStatus;
    }

    public void setHttpStatus(int httpStatus) {
        this.mHttpStatus = httpStatus;
    }

    public int getErrorCode() {
        return mErrorCode;
    }

    public void setErrorCode(int errorCode) {
        this.mErrorCode = errorCode;
    }

    public boolean isConnected() {
        return mIsConnected;
    }

    public void setIsConnected(boolean mIsConnected) {
        this.mIsConnected = mIsConnected;
    }

    public String getErrorMessage() {
        return mErrorMessage;
    }

    public void setErrorMessage(String mErrorMessage) {
        this.mErrorMessage = mErrorMessage;
    }

    public JSONObject getJSON() {
        return mJSON;
    }

    public void setJSON(JSONObject mJSON) {
        this.mJSON = mJSON;
    }

    public String getData() {
        return mData;
    }

    public void setData(String data) {
        this.mData = data;
    }

    @Override
    public String toString() {
        StringBuilder  sb = new StringBuilder();
        sb.append("mHttpStatus=");
        sb.append(mHttpStatus);
        sb.append(";");
        sb.append("mErrorCode=");
        sb.append(mErrorCode);
        sb.append(";");
        sb.append("mErrorMessage=");
        sb.append(mErrorMessage);
        sb.append(";");
        sb.append("mJSON=");
        sb.append(mJSON);
        sb.append(";");
        return sb.toString();
    }
}
